package com.zmn.brs.admin.controller.rule.base;

import com.zmn.brs.common.enums.EventTypeEnum;
import com.zmn.brs.model.entity.event.Event;
import com.zmn.brs.model.entity.event.EventQuery;
import com.zmn.brs.model.query.rule.ObjectiveRuleCustomQuery;
import com.zmn.brs.services.interfaces.event.EventService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.RedirectView;

import javax.annotation.Resource;


/**
 * 描述： 规则
 * @author chongw
 * @since 2021-05-28 17:05:29
 */
@Controller
@RequestMapping("/brs/rule/")
public class AlarmRuleListController extends AlarmRuleBaseController {

    @Resource
    EventService eventService;

    /**
     * 规则列表
     * @author chongw
     * @param query
     * @since 2021-07-02 17:05:29
     */
    @RequestMapping("list")
    public ModelAndView list(@ModelAttribute EventQuery query){
        Event event = eventService.findById(query.getEventId());
        ModelAndView mav = new ModelAndView();
        RedirectView view = new RedirectView(EventTypeEnum.getEventTypeEnum(event.getEventType()).getRuleUrl() + "?eventId=" + event.getEventId(),true,false);
        mav.setView(view);
        return mav;
    }

}
